package java_常用api;

public class API_5_高级数组操作2_冒泡排序 {
    public static void main(String[] args) {
        int[] list = {7,4,1,9,3};
        int[] list2 = sort(list);

        for (int j = 0; j < 5; j++) {
            System.out.print(list2[j]);
        }
    }

    private static int[] sort(int[] list) {
        int o =1;
        for (int y = 0; y < list.length-1; y++) {


            // 对比一次
            for (int i = 0; i < list.length-1-y; i++) {
                if (list[i] > list[i + 1]) {
                    int x = list[i];
                    list[i] = list[i + 1];
                    list[i + 1] = x;


                }
            }

        }   return list;
    }
}
